package com.hospital.dao;

import com.hospital.domain.Caserecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CaserecordDao {

    @Select("select * from caserecordinfo,registinfo,doctorinfo,userinfo " +
            "where caserecordinfo.registID = registinfo.registID " +
            "and registinfo.userID = #{id} " +
            "and registinfo.doctorID = doctorinfo.doctorID " +
            "and registinfo.userID = userinfo.userID")
    public List<Caserecord> selectCaserecordByUserID(int id);


    @Insert("insert into caserecordinfo values " +
            "(null,#{therapyCycle},#{checkSituation},#{diseaseType},#{medicalAdvice},now(),#{registID},0)")
    public int addCaserecord(Caserecord caserecord);

    @Select("SELECT grade FROM caserecordinfo WHERE caseID = #{caseID}")
    public int isGrade(int caseID);

    @Update("UPDATE caserecordinfo SET grade = #{rate} WHERE caseID = #{caseID};")
    public int addRate(@Param("caseID") int caseID,@Param("rate") int rate);

}